<?php
$modelUser       = new Users();
$modelUser->type = $type;
?>
<link type="text/css" rel="stylesheet" href="<?php echo $this->assetDirWeb ?>css/Webmaster/user.css" />
<?php if (!$data): ?>

<?php else: ?>
    <div class="table-responsive">
        <table class="table table-bordered table-striped table-condensed">
            <thead>
                <tr>
                    <th><?php echo $sort->link('business_name', $modelUser->getAttributeLabel('name')) ?></th>
                    <th><?php echo $modelUser->getAttributeLabel('email') ?></th>

                    <?php if ($type == Users::TYPE_CUSTOMER OR $type == Users::TYPE_STAFF): ?>
                        <th>Merchant</th>
                    <?php endif; ?>

                    <th><?php echo $modelUser->getAttributeLabel('status') ?></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($data as $item): ?>
                    <tr data="<?php $item->id ?>">
                        <td>
                            <a class="quick-detail" data-rel="popover"                            
                               data-html="true" data-delay="1" data-trigger="click"
                               data-content='<?php
                               echo $this->renderPartial('//user/_quick_detail', array(
                                   'user' => $item,
                                   'type' => $type));
                               ?>' >
                                   <?php echo $item->name ?>
                            </a>
                        </td>
                        <td><?php echo $item->email ?></td>

                        <?php if ($type == Users::TYPE_CUSTOMER): ?>
                            <td>    <?php echo htmlentities(@$item->biz->name, ENT_QUOTES); ?></td>
                        <?php endif; ?>

                        <?php if ($type == Users::TYPE_STAFF): ?>
                            <td><?php echo htmlentities(@$item->author->name, ENT_QUOTES); ?></td>
                        <?php endif; ?>

                        <td><?php echo $item->statusLabel ?></td>

                        <td class="center">
                            <?php if ($type == Users::TYPE_BUSINESS): ?>
                                <a href="<?php echo $item->bookUrl ?>" class="btn btn-success">
                                    <i class="icon-calendar"></i>                                            
                                </a>
                            <?php endif; ?>
                            <?php if (!$this->isStaff AND $type == Users::TYPE_CUSTOMER): ?>
                                <a href="<?php echo $item->packageUrl ?>" class="btn btn-warning">
                                    <i class="icon-briefcase"></i>&nbsp;Package
                                </a>&nbsp;
                                <a href="<?php echo $item->createRetailOrderUrl ?>" class="btn btn-success">
                                    <i class="icon-briefcase"></i>&nbsp;Create Retail Order
                                </a>
                            <?php endif; ?>

                            <?php if ($item->id != Users::SUPER_ADMIN OR $type == Users::TYPE_CUSTOMER): ?>
                                <?php if ($this->checkAccess('edit', '', TRUE)): ?>
                                    <a href="<?php echo $item->editUrl ?>" class="btn btn-info"
                                       onclick="return editItem($(this))">
                                        <i class="icon-edit "></i>                                            
                                    </a>
                                <?php endif; ?>

                                <?php if ($this->checkAccess('delete', '', TRUE)): ?>
                                <!--                                <a class="btn btn-danger" href="//<?php echo $item->deleteUrl ?>"
                                                                   onclick="return deleteItem($(this))">
                                                                    <i class="icon-trash "></i> -->
                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
<?php endif; ?>
<div class="pagination pagination-centered">
    <?php
    $this->widget('application.widgets.MyLinkPager', array(
        'pages'                => $pages,
        'header'               => '',
        'maxButtonCount'       => 5,
        'nextPageLabel'        => '&raquo;',
        'firstPageLabel'       => '←',
        'lastPageLabel'        => '→',
        'prevPageLabel'        => '&laquo;',
        'selectedPageCssClass' => 'active',
    ))
    ?>
</div>
